package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.common.util.AjaxResult;
import cn.wolfcode.luowowo.flight.domain.FlightCity;
import cn.wolfcode.luowowo.flight.service.IFlightService;
import cn.wolfcode.luowowo.flight.util.FlightUtil;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/flight")
public class FlightController {
    @Reference
    private IFlightService flightService;

    //获取国内所有机场城市信息
    @RequestMapping("index")
    public String index(Model model){
        model.addAttribute("hotFlights", flightService.getHot());
        model.addAttribute("initialA", flightService.getABCDE());
        model.addAttribute("initialF", flightService.getFGHJ());
        model.addAttribute("initialK", flightService.getKLMNP());
        model.addAttribute("initialQ", flightService.getQRSTW());
        model.addAttribute("initialX", flightService.getXYZ());
        return "flight/index";
    }

    //发送获取航班信息
    @RequestMapping("search")
    @ResponseBody
    public AjaxResult getFlightInfo(String orgCity,String dstCity,String depTime){

        return FlightUtil.getFlightInfo(orgCity, dstCity, depTime);
    }

}
